<?php

class Utility_DateFunctions {

    static public function secs_to_hours_mins_secs($secs) {

        $secs = (int) $secs;

        $hours = (int) ($secs / (60 * 60));
        $secs -= ($hours * (60 * 60));

        $mins  = (int) ($secs / 60);
        $secs -= ($mins * 60);

        return sprintf("%'02d:%'02d:%'02d", $hours, $mins, $secs);
    }
    
    static public function toInt($str_date) {
        $time = strtotime($str_date);
        return date('YmdHis', $time);
    }

    static public function getNumberOfWeekdaysBetween($startDate, $endDate) {

        $step = strtotime($startDate);
        $end  = strtotime($endDate);

        $weekdays = 0;
        while($step < $end) {
            if(in_array(date('N', $step), array('1', '2', '3', '4', '5'))) {
                $weekdays++;
            }

            $step = mktime(0, 0, 0, date('m', $step), date('d', $step) + 1, date('Y', $step));
        }

        return $weekdays;
    }

}
